<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php use_stylesheet('order.css') ?>
<?php
$order = $form->getObject();//get the client order object

slot('title', sprintf('Order name: %s', $order->getOrdername()));
?>
<?php if ($sf_request->getParameter('idorder') == $order->getIdorder()): ?>
  <?php include_partial('order/admin', array('order' => $order)) ?>
<?php endif ?>



<?php echo form_tag_for($form, '@order') ?>
  <table id="order_form">
  <tbody>
    <tr>
      <th>Order identifier</th>
      <td><?php echo $order->getIdorder() ?></td>
    </tr>
    <tr>
      <th>Order name</th>
      <td><?php echo $order->getOrdername() ?></td>
    </tr>
    <tr>
      <th>Text category</th>
      <td><?php echo $order->getTextcategories(); ?></td>
    </tr>

    <tr>
      <th>Website</th>
      <td>
        <?php
        if ($order->getIsWebsite()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Print</th>
      <td>
        <?php
        if ($order->getIsPrint()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Newsletter</th>
      <td>
        <?php
        if ($order->getIsNewsletter()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Poster</th>
      <td>
        <?php
        if ($order->getIsPoster()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Blog</th>
      <td>
        <?php
        if ($order->getIsBlog()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Other text media</th>
      <td><?php echo $order->getOthertextmedium() ?></td>
    </tr>
    <tr>
      <th>Target group</th>
      <td><?php echo $order->getTargetgroup() ?></td>
    </tr>
    <tr>
      <th>Existing customer</th>
      <td>
        <?php
        if ($order->getIsExistingCustormer()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>New customer</th>
      <td>
        <?php
        if ($order->getIsNewCustomer()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Women</th>
      <td>
        <?php
        if ($order->getIsWomen()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Men</th>
      <td>
        <?php
        if ($order->getIsMen()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?>
      </td>
    </tr>
    <tr>
      <th>Style</th>
      <td><?php echo $order->getFormalstyle() ?></td>
    </tr>
    <tr>
      <th>Person style</th>
      <td><?php echo $order->getPersonstyle() ?></td>
    </tr>
    <tr>
      <th>Emotion style</th>
      <td><?php echo $order->getEmotionstyle() ?></td>
    </tr>
    <tr>
      <th>Formulate</th>
      <td><?php echo $order->getFormulatetext() ?></td>
    </tr>
    <tr>
      <th>Free Text</th>
      <td><?php echo $order->getFreetext() ?></td>
    </tr>
    <tr>
      <th>Image</th>
      <td>
        <img src="/uploads/orders/<?php echo $order->getUrlimagestructure() ?>" alt="<?php echo $order->getOrdername() ?> Image" />        
        <?php //echo $order->getUrlimagestructure()  ?>
      </td>
    </tr>
    <tr>
      <th>Standard</th>
      <td>
        <?php
        if ($order->getIsStandard()) {
          echo "&#x2713;";
        } else {
          echo "x";
        }
        ?></td>
    </tr>
    <tr>
      <th>Edition options</th>
      <td colspan="5">
        <?php 
        $tech = "False";
        $foraign = "False";
        $superlative = "False";
        $oldLang = "False";
        $startSent = "False";


        if ($order->getEditionoptions()->getIsTechnicalTerms()) {
          $tech = "true";
        }
        if ($order->getEditionoptions()->getIsForaignWord()) {
          $foraign = "true";
        }
        if ($order->getEditionoptions()->getIsSuperlative()) {
          $superlative = "true";
        }
        if ($order->getEditionoptions()->getIsOldLanguage()) {
          $oldLang = "true";
        }
        if ($order->getEditionoptions()->getIsStartOfSentence()) {
          $startSent = "true";
        }
        $ownC = "";
        if ($order->getEditionoptions()->getOwnchoice()->getText() != null)
        {
          $ownC = $order->getEditionoptions()->getOwnchoice()->getText();
        }
        
        
        echo sprintf("Technical terms: %s | Foraign words: %s | 
          Superlative: %s | Old language: %s | Start of sentence: %s | Own Choice: %s ",
                $tech,$foraign,$superlative,$oldLang, $startSent, $ownC);
        ?>
      </td>

    </tr>
    

<!--    <tbody>-->
      <?php 

//      $i = 0;
//      if ($form->hasErrors())
//      {
//        echo "errores :S";
//      }
//      while ($i < $form->getFormFieldSchema()->count()){
//
//        if($form->getFormFieldSchema()->current()->getName() == 'editionoptionsid')
//        {
//          $j = 0;
//
//            echo $form->getFormFieldSchema()->current()->getWidget()->render('editionoptionsid');
//
//        }
//        elseif(($form->getFormFieldSchema()->current()->getName() == 'othertextmediumid'))
//        {
//           print_r($form->getFormFieldSchema()->current()->__toString());//current()->getValue());
//        }
//        elseif(($form->getFormFieldSchema()->current()->getName() != '_csrf_token'))
//        {
//          if($form->getFormFieldSchema()->current()->getName() != 'idorder')
//            {
//            echo $form->getFormFieldSchema()->current()->renderRow();//->getName();
//          }
//            
//        }
//          
//        
//        $form->getFormFieldSchema()->next();
//
//        $i++;
//      }
      
     
      ?>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="2">
          &nbsp;<a href="<?php echo url_for('order/index') ?>">Back to list</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'order/delete?idorder=' . $form->getObject()->getIdorder(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input type="submit" value="Preview your order" />
        </td>
      </tr>
    </tfoot>
  </table>
</form>
